﻿using System;
using System.Windows;
using System.Windows.Navigation;
using OFX.Aggregator.WpfApplication.Properties;

namespace OFX.Aggregator.WpfApplication
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : NavigationWindow
	{
		public MainWindow()
		{
			InitializeComponent();

			Rect bounds = Settings.Default.WindowPosition;

			if (bounds != new Rect(0, 0, 0, 0))
			{
				Top = bounds.Top;
				Left = bounds.Left;

				if (SizeToContent == SizeToContent.Manual)
				{
					Width = bounds.Width;
					Height = bounds.Height;
				}
			}
		}

		private void NavigationWindow_Closed(object sender, EventArgs e)
		{
			if (WindowState == WindowState.Normal)
			{
				Settings.Default.WindowPosition = new Rect(Left, Top, Width, Height);
			}
			else
			{
				Settings.Default.WindowPosition = RestoreBounds;
			}
		}
	}
}